package com.east.controller.task;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.east.bean.Staff;
import com.east.bean.Task;
import com.east.bean.User;
import com.east.service.task.TaskPersonalService;
import com.east.service.task.TaskService;
import com.east.utils.BaseUtil;
import com.east.utils.PageJson;
import com.east.utils.Pagenation;
import com.east.utils.Result;
import com.east.utils.ResultUtil;
import com.github.pagehelper.Page;
/**
 * 	个人
 * @author gs
 * @date  2020年3月10日
 */
@RestController
@RequestMapping("taskP")
public class TaskPersonalController {
	@Autowired
    private TaskService taskService;
	@Autowired
    private TaskPersonalService taskPersonalService;
	/**
	 * 个人分页
	 * @param pagenation
	 * @param task
	 * @return
	 */
	@GetMapping("all")
    //@RequiresPermissions("task:all")
   public Result findAll(Pagenation pagenation,Task task){
		User user = BaseUtil.Token();
	    Page<Task> tasks = taskPersonalService.findTask(pagenation, task, user);
	    Object pageJson = new PageJson<Task>().pageJson(tasks);
	    return ResultUtil.success(pageJson);
   }
	/**
	 * 个人处理数量
	 * @param task
	 * @return
	 */
	@GetMapping("count")
    //@RequiresPermissions("task:all")
   public Result findcount(Task task){
		User user = BaseUtil.Token();
	    Map<String, Integer> tasks = taskPersonalService.findCount(task, user);
	    return ResultUtil.success(tasks);
   }
	/**
	 * 部门统计  
	 * 部门工作量、人员情况、类型情况
	 * @param task
	 * @return
	 */
   @GetMapping("countP")
   public Result findcountPr(Task task){
		User user = BaseUtil.Token();
	    Map<String, Integer> tasks = taskPersonalService.findCountP(task, user);
	    return ResultUtil.success(tasks);
   }
   /**
    	* 部门统计人数
    * @param pagenation
    * @param task
    * @return
    */
   @GetMapping("staff")
   public Result findstaff(Pagenation pagenation,Task task){
		User user = BaseUtil.Token();
		 Page<Staff> tasks = taskPersonalService.findStaff(pagenation, user,task);
		 Object pageJson = new PageJson<Staff>().pageJson(tasks);
		    return ResultUtil.success(pageJson);
   }
   /**
		* 部门统计人数
	* @param pagenation
	* @param task
	* @return
	*/
	@GetMapping("staffX")
	public Result findstaffX(Pagenation pagenation,Task task){
		User user = BaseUtil.Token();
		 Page<Task> tasks = taskPersonalService.findStaffX(pagenation, user,task);
		 Object pageJson = new PageJson<Task>().pageJson(tasks);
		    return ResultUtil.success(pageJson);
	}
   /**
	* 部门统计人数
	* @param pagenation
	* @param task
	* @return
	*/
	@GetMapping("project")
	public Result findproject(Pagenation pagenation,Task task){
			User user = BaseUtil.Token();
		 Page<Task> tasks = taskPersonalService.findProject(pagenation, user);
		 Object pageJson = new PageJson<Task>().pageJson(tasks);
		    return ResultUtil.success(pageJson);
	}


}
